package com.unitlib.net.config;

import android.app.Application;

import com.unitlib.net.utils.SSLSocketClient;

import java.io.File;
import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;
import rxhttp.wrapper.annotation.DefaultDomain;
import rxhttp.wrapper.cookie.CookieStore;

import rxhttp.wrapper.param.RxHttp;

public class NetConfig {

    @DefaultDomain //设置为默认域名
    public static String BASE_URL = "";

    public static void init(Application app, String baseUrl, boolean isDebug) {
        // 网络设置
        File file = new File(app.getExternalCacheDir(), "RxHttpCookie");
        OkHttpClient client = new OkHttpClient.Builder()
                .cookieJar(new CookieStore(file))
                .connectTimeout(10, TimeUnit.SECONDS)
                .readTimeout(30, TimeUnit.SECONDS)
                .writeTimeout(30, TimeUnit.SECONDS)
                .hostnameVerifier(new SSLSocketClient().getHostnameVerifier())
                .build();
        RxHttp.init(client, isDebug);
        BASE_URL = baseUrl;
    }

}
